You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
const Gunner = require('./gunner');
|
|
const gunner = new Gunner();
|
|
|
|
gunner.test('should automatically pass', expect => expect().done());
|
|
gunner.test(`should be equal`, expect => expect(1).equal(1));
|
|
gunner.test(`objects are deep equal`, expect => expect({ a: 1 }).deepEqual({ a: 1 }));
|
|
gunner.test(`objects aren't deeply equal`, expect => expect({a : 1}).deepEqual({ a: 2 }));
|
|
|
|
const a = 1;
|
|
gunner.test('expression should be true', expect => expect(a === 1).isTrue());
|
|
gunner.test('promise must reject', expect =>
|
|
expect(Promise.reject(new Error('Promise Rejected'))).equal('no rejection'));
|
|
|
|
gunner.test('multiple expect', expect => {
|
|
|
|
const a = { };
|
|
a.b = 1;
|
|
a.c = 2;
|
|
|
|
return [
|
|
expect(a).hasProp('b'),
|
|
expect(a).hasPair('c', 3),
|
|
];
|
|
|
|
});
|
|
|
|
const flamethrower = require('./throwingFunc');
|
|
|
|
gunner.test('should catch error', expect => {
|
|
return expect(flamethrower()).equal(5);
|
|
});
|
|
|
|
gunner.test('should be a Promise (resolved)', expect =>
|
|
expect(Promise.resolve()).isPromise());
|
|
|
|
gunner.test('should be a Promise (rejected)', expect =>
|
|
expect(Promise.reject()).isPromise());
|
|
|
|
gunner.test('should resolve to 5', expect =>
|
|
expect(Promise.resolve(5)).resolvesTo(5));
|
|
|
|
gunner.test('should not resolve to 5', expect =>
|
|
expect(Promise.resolve()).resolvesTo(5));
|
|
|
|
gunner.run({ trace: false });
|
|
|