Lint money.spec.ts

This commit is contained in:
Eric 2020-06-26 19:22:45 -05:00 committed by Eric Schultz
parent f928072c12
commit 4e51e9ecfc
2 changed files with 26 additions and 23 deletions

View file

@ -6,7 +6,6 @@ log/*
coverage/*
# old ts files we want to migrate
app/javascript/common/money.spec.ts
app/javascript/donate-button/donate-button.v2.ts
app/javascript/legacy_react/api/api/api.ts
app/javascript/legacy_react/api/api/NonprofitsApi.ts

View file

@ -1,30 +1,34 @@
import {Money} from './money'
import 'jest';
import { Money } from './money';
describe("Money", () => {
describe('Money.fromCents',() => {
describe('Money.fromCents', () => {
it('succeeds from a old Money object', () => {
const old = Money.fromCents(333, 'eur')
expect.assertions(2);
const old = Money.fromCents(333, 'eur');
const result = Money.fromCents(old)
expect(result).toEqual(old)
const result = Money.fromCents(old);
expect(result).toStrictEqual(old);
expect(result).not.toBe(old)
})
expect(result).not.toBe(old);
});
it('succeeds from a json', () => {
const old = {amount:333, currency:'eur'}
expect.hasAssertions();
const old = { amount: 333, currency: 'eur' };
const result = Money.fromCents(old)
expect(result).toEqual(old)
const result = Money.fromCents(old);
// eslint-disable-next-line jest/prefer-strict-equal
expect(result).toEqual(old);
expect(result).toBeInstanceOf(Money)
})
expect(result).toBeInstanceOf(Money);
});
it('succeeds from function parameters', () => {
const result = Money.fromCents(333, 'eur')
expect(result).toEqual({amount:333, currency:'eur'})
expect.hasAssertions();
const result = Money.fromCents(333, 'eur');
// eslint-disable-next-line jest/prefer-strict-equal
expect(result).toEqual({ amount: 333, currency: 'eur' });
expect(result).toBeInstanceOf(Money)
})
})
})
expect(result).toBeInstanceOf(Money);
});
});
});