@tvkitchen/countertop
Version:
The entry point for developers who want to set up a TV Kitchen.
48 lines (46 loc) • 1.32 kB
JavaScript
;
var _ = require("..");
describe('index', () => {
describe('methodExists', () => {
it('should return false if the method does not exist', () => {
const x = {};
expect((0, _.methodExists)('foo', x)).toBe(false);
});
it('should return false if the attribute is not a method', () => {
const x = {
foo: 'bar'
};
expect((0, _.methodExists)('foo', x)).toBe(false);
});
it('should return true if the method does exist', () => {
const x = {
foo: () => 'bar'
};
expect((0, _.methodExists)('foo', x)).toBe(true);
});
});
describe('arraysHaveOverlap', () => {
it('should return false if they share no common elements', () => {
expect((0, _.arraysHaveOverlap)([1, 2, 3], [4, 5])).toBe(false);
expect((0, _.arraysHaveOverlap)([], [4, 5])).toBe(false);
});
it('should return true if they share common elements', () => {
expect((0, _.arraysHaveOverlap)([1, 2, 3], [4, 5, 1])).toBe(true);
});
});
describe('by', () => {
it('should return a function that sorts correctly', () => {
const fn = (0, _.by)('id');
expect(fn({
id: 1
}, {
id: 2
})).toBe(-1);
expect(fn({
id: 2
}, {
id: 1
})).toBe(1);
});
});
});