test("add", t => { t.truthy(add, "add is defined"); let table = empty; const key = 1; table = add(table, key, 0); t.is(table.size, 1, "add increases the size of the table when given an Array"); t.is(table.get(key).size, 1, "add increases the size of the set at the key"); t.truthy(Set.isSet(table.get(key)), "the object at the key is an Immutable Set"); table = add(table, key, 1); t.is(table.size, 1, "consequtive adds to the same key do not add to the size of the map"); t.is(table.get(key).size, 2, "add increases the size of the Set at the key given"); table = add(table, key, Set.of(1)); t.is(table.get(key).size, 2, "attempting to add an already existing value does not work"); table = add(table, 2, 1); t.is(table.size, 2, "add to a different key increase the size of the map"); t.is(table.get(2).size, 1, "add increases the size of the Set at the key given"); });
describe('Results',()=>{ it('renders entries with vote counts or zero',()=>{ const pair=List.of('Trainspotting','28 days later'); const tally=Map({'Trainspotting':5}); const component=renderIntoDocument(<Results pair={pair} tally={tally}/>); let nextInvoke=false; const next=()=>nextInvoke=true; const pair=List.of('Trainspotting','28 days later'); const tally=Map({}); const component=renderIntoDocument(<Results pair={pair} tally={tally} next={next}/>)
const foodsMap = (state = Map({}), action) => { switch (action.type) { case 'ADD_FOOD': if (state.get(action.id)) { return state.set(action.id, foods(state.get(action.id), action)); } return state.set(action.id, List.of(Map({ name: action.name, price: action.price, original_price: action.original_price, count: action.count, addtional: action.addtional, image_hash: action.image_hash }))); case 'REDUCE_COUNT': if (foods(state.get(action.id), action).isEmpty()) { return state.delete(action.id); } return state.set( action.id, foods( state.get(action.id), action ) ); default: return state; } }
describe('TodoList', () => { it('renders a list with only completed items if the filter is completed', () => { const todos = List.of( Map({id: 1, text: 'React', status: 'active'}), Map({id: 2, text: 'Redux', status: 'active'}), const todos = List.of( Map({id: 1, text: 'React', status: 'active'}), Map({id: 2, text: 'Redux', status: 'active'}),
let oldMovies=List.of('NewYork',"10000 Years history"); let newMoive="One night"; let nextState=AddMovie(oldMovies,newMoive); expect(nextState).to.equal(List.of( "NewYork","10000 Years history","One night" )); expect(oldMovies).to.equal(List.of( "NewYork","10000 Years history" )); movie:List.of('NewYork',"10000 Years history") }); let newMoive="One night"; let nextState=AddMovie(state,newMoive); expect(nextState).to.equal(Map({ "movie":List.of( "NewYork","10000 Years history","One night" )})); expect(state).to.equal(Map({ movie:List.of('NewYork',"10000 Years history") })) });
describe('Results', () => { const pair = List.of('Trainspotting', '28 Days Later'); const tally = Map({'Trainspotting': 5}); const component = renderIntoDocument( const next = () => nextInvoked = true; const pair = List.of('Trainspotting', '28 Days Later'); const component = renderIntoDocument( <Results pair={pair} const pair = List.of('Trainspotting', '28 Days Later'); const component = renderIntoDocument( <Results pair={pair}
describe('TodoList', () => { it('renders a list with only the active items if the filter is active', () => { const todos = List.of( Map({id: 1, text: 'React', status: 'active'}), Map({id: 2, text: 'Redux', status: 'active'}), const todos = List.of( Map({id: 1, text: 'React', status: 'active'}), Map({id: 2, text: 'Redux', status: 'active'}), const todos = List.of( Map({id: 1, text: 'React', status: 'active'}), Map({id: 2, text: 'Redux', status: 'active'}),
describe('Results', () => { it('renders entries with vote counts or zero', () => { const pair = List.of('Trainspotting', '28 Days Later'); const tally = Map({'Trainspotting': 5}); const component = renderIntoDocument( let nextInvoked = false; const next = () => nextInvoked = true; const pair = List.of('Trainspotting', '28 Days Later'); const component = renderIntoDocument( <Results pair={pair}