How to use the ava.test function in ava

To help you get started, we’ve selected a few ava examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adrianabreu / SIMDE-Simulator / src / Code.spec.ts View on Github external
const input = `7
ADDI R2 R0 #3
BGT R0 R2 ET1
ADDI R3 R0 #2
ET1:
SUB R4 R3 R2
BGT R2 R3 ET2
SUB R5 R2 R3
ET2:
SUB R6 R2 R3
    `;
	let code: Code = new Code();
	t.notThrows(() => code.load(input));
})

test('Example code 11 does not throws errors', t => {
	const input = `26
	ADDI	R33 R0 #-1
	ADDI	R34 R0 #400
	ADDI	R1 R0 #-1
	ADDI	R2 R0 #10
// Inicialización de la pila
	ADDI	R31 R0 #500
// Bucle principal
INI:
	LW	R3 (R2)
	LW	R4 1(R2)
// Se guarda el nodo visitado
	SW	R3 (R34)
	ADDI	R34 R34 #1
BUC:
// Si no tiene hijos es un nodo hoja y no hay que recorrer nada
github thinkjs / think-model / test / mysql / instance / parser.js View on Github external
t.is(key, "lizheming")
});

ava.test('parseValue, null', t => {
  let instance = new Parser();
  let key = instance.parseValue(null);
  t.is(key, "null")
});

ava.test('parseValue, boolean, true', t => {
  let instance = new Parser();
  let key = instance.parseValue(true);
  t.is(key, "1")
});

ava.test('parseValue, boolean, false', t => {
  let instance = new Parser();
  let key = instance.parseValue(false);
  t.is(key, "0")
});

ava.test('parseValue, object', t => {
  let instance = new Parser();
  let key = instance.parseValue({});
  t.deepEqual(key, {});
});

ava.test('parseField, empty', t => {
  let instance = new Parser();
  let key = instance.parseField();
  t.deepEqual(key, '*')
});
github thinkjs / think-model / test / mysql / relation.js View on Github external
instance.getRelation = function(data, options){
    return Promise.resolve([{name: 1}]);
  }
  
  let data = await instance.afterFind([], {});
  t.deepEqual(data, [{name: 1}]);
})
test('afterSelect', async t => {
  let instance = new Relation('user', DBConfig);
  instance.getRelation = function(data, options){
    return Promise.resolve([{name: 1}]);
  }
  let data = await instance.afterSelect([], {});
  t.deepEqual(data, [{name: 1}]);
})
test('getRelation, data empty', async t => {
  let instance = new Relation('user', DBConfig);
  let data = await instance.getRelation([]);
  t.deepEqual(data, []);
})
test('getRelation, relation empty', async t => {
  let instance = new Relation('user', DBConfig);
  let data = await instance.getRelation([{name: 1}], {});
  t.deepEqual(data, [{name: 1}]);
})
test('getRelation, _relationName empty', async t => {
  let instance = new Relation('user', DBConfig);
  instance.relation = {cate: Relation.HAS_ONE}
  instance._relationName = false;
  let data = await instance.getRelation([{name: 1}], {});
  t.deepEqual(data, [{name: 1}]);
})
github pagarme / escriba / test / unit / message-masker.js View on Github external
test('messageMasker: mask password with a regex', t => {
  const messageMasker = createMessageMasker({
    password: {
      paths: ['password'],
      pattern: /\w.*/g,
      replacer: '*'
    }
  })

  const object = { password: 'Papyrus' }  
  const maskedObject = messageMasker(object)
  t.deepEqual(maskedObject, { password: '*' })
})

test('messageMasker: mask password from an object without this property', t => {
  const messageMasker = createMessageMasker({
    password: {
      paths: ['password'],
      pattern: /\w.*/g,
      replacer: '*'
    }
  })
  
  const object = { name: 'Pagar.me', library: 'Papyrus' }
  const maskedObject = messageMasker(object)
  t.deepEqual(maskedObject, object)
})

test('messageMasker: mask password value in differents paths', t => {
  const messageMasker = createMessageMasker({
    password: {
github thinkjs / think-model / test / mysql / instance / parser.js View on Github external
t.is(data, 'SELECT * FROM user')
});

ava.test('parseThinkWhere, _query', t => {
  let instance = new Parser();
  let data = instance.parseThinkWhere('_query', 'name=lizheming&name1=suredy');
  t.is(data, 'name = \'lizheming\' AND name1 = \'suredy\'')
});

ava.test('parseThinkWhere, _query, with logic', t => {
  let instance = new Parser();
  let data = instance.parseThinkWhere('_query', 'name=lizheming&name1=suredy&_logic=OR');
  t.is(data, 'name = \'lizheming\' OR name1 = \'suredy\'')
});

ava.test('parseThinkWhere, _query, object', t => {
  let instance = new Parser();
  let data = instance.parseThinkWhere('_query', {name: 'lizheming', name1: 'suredy'});
  t.is(data, 'name = \'lizheming\' AND name1 = \'suredy\'')
});

ava.test('parseWhere, empty', t => {
  let instance = new Parser();
  let data = instance.parseWhere();
  t.is(data, '')
});

ava.test('parseWhere, empty 1', t => {
  let instance = new Parser();
  let data = instance.parseWhere({_logic: 'AND'});
  t.is(data, '')
});
github AlexanderLindsay / dailybudgeteer / test / testRate.ts View on Github external
const expected = amount / month.daysInMonth();

    let r = new Rate("test", amount, 1, it.IntervalType.Month);
    t.is(r.perDiem(month), expected);
});

ava.test("perDiem - month - april2016", (t) => {
    const amount = -25;
    const month = moment([2016, 3, 1]);
    const expected = amount / month.daysInMonth();

    let r = new Rate("test", amount, 1, it.IntervalType.Month);
    t.is(r.perDiem(month), expected);
});

ava.test("perDiem - year - non leap", (t) => {
    const amount = -25;
    const year = moment([2015, 1, 1]);
    const expected = amount / 365;

    let r = new Rate("test", amount, 1, it.IntervalType.Year);
    t.is(r.perDiem(year), expected);
});

ava.test("perDiem - year - leap", (t) => {
    const amount = -25;
    const year = moment([2016, 1, 1]);
    const expected = amount / 366;

    let r = new Rate("test", amount, 1, it.IntervalType.Year);
    t.is(r.perDiem(year), expected);
});
github thinkjs / think-model / test / relation / base.js View on Github external
const {test} = require('ava');
const Relation = require('../../lib/relation/base');
test('instance normal', t => {
  t.plan(3);

  const relation = new Relation(1, 2, 3);
  t.is(relation.data, 1);
  t.is(relation.options, 2);
  t.is(relation.model, 3);
});

test('relation where parse data object empty key', t => {
  const relation = new Relation({
    title: 'hello1',
    content: 'world1'
  }, {
    key: 'id',
    fkey: 'post_id'
  }, []);
github thinkjs / think-model / test / base.js View on Github external
}
    }
  }
  var data = instance.beforeAdd({username: 'lizheming', meta: {
    updateAt: 4
  }});
  t.deepEqual(data, {
    name: 'lizheming',
    username: 'lizheming',
    meta: {
      createAt: 1,
      updateAt: 4
    }
  });
})
ava.test('beforeAdd, has depth 4', t => {
  var instance = new Base('user', DBConfig);
  instance.schema = {
    name: {
      type: 'string',
      default: function() { return this.username; }
    },
    meta: {
      createAt: {
        default: function () { return 1 }
      }
    }
  }
  var data = instance.beforeAdd({username: 'lizheming', meta: {
    createAt: 5,
    updateAt: 4
  }});
github mobxjs / mobx-state-tree / test / protect.ts View on Github external
() => {
            applySnapshot(store, { todos: [{ title: 'Get tea' }] })
        },
        "[mobx-state-tree] Cannot modify 'Todo@', the object is protected and can only be modified by using an action."
    )

    t.throws(() => {
        store.todos.push({ title: 'test' } as any)
    }, "[mobx-state-tree] Cannot modify 'Todo[]@/todos', the object is protected and can only be modified by using an action.")

    t.throws(() => {
        store.todos[0].title = 'test'
    }, "[mobx-state-tree] Cannot modify 'Todo@/todos/0', the object is protected and can only be modified by using an action.")
})

test('protect should also protect children', t => {
    const store = createTestStore()

    t.throws(() => {
        store.todos[0].title = 'B'
    }, "[mobx-state-tree] Cannot modify 'Todo@/todos/0', the object is protected and can only be modified by using an action.")

    store.todos[0].setTitle('B')
    t.is(store.todos[0].title, 'B')
})

test('unprotected mode should be lost when attaching children', t => {
    const store = Store.create({ todos: [] })
    const t1 = Todo.create({ title: 'hello' })
    unprotect(t1)

    t.is(isProtected(t1), false)
github mitch-b / typedeck / src / models / chip / standardChip.spec.ts View on Github external
const chip = new StandardChip(chipColor);
  t.deepEqual(chip.color, chipColor);
  t.deepEqual(chip.getValue(), expectedValue);
  t.deepEqual(chip.getValue(chipColor), expectedValue);
});

test('chip black is 100', async t => {
  const chipColor = ChipColor.Black;
  const expectedValue = 100;
  const chip = new StandardChip(chipColor);
  t.deepEqual(chip.color, chipColor);
  t.deepEqual(chip.getValue(), expectedValue);
  t.deepEqual(chip.getValue(chipColor), expectedValue);
});

test('brown chip throws exception', async t => {
  const chipColor = ChipColor.Brown;
  const chip = new StandardChip(chipColor);

  try {
    chip.getValue();
    t.fail('Error should have thrown');
  } catch (err) {
    t.deepEqual(err.message, `Unable to determine value of ${ChipColor[chipColor]} Chip for ${ChipColorType[ChipColorType.Standard]}`);
  }
});