{"size": 453, "ext": "js", "max_stars_repo_path": "src/js/memoize/__test__/memoize.test.js", "max_stars_repo_name": "fijiwebdesign/frontend-webpack-boilerplate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/js/memoize/__test__/memoize.test.js", "max_issues_repo_name": "fijiwebdesign/frontend-webpack-boilerplate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/memoize/__test__/memoize.test.js", "max_forks_repo_name": "fijiwebdesign/frontend-webpack-boilerplate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.6470588235, "max_line_length": 77, "alphanum_fraction": 0.5165562914}
import assert from 'assert'
import memoize from '../memoize'

describe('memoize', () => {

    it('executes fn only once', () => {
        const memo = memoize(() => Math.random())
        assert(memo() === memo())
    })

    it('resolves async fns', () => {
        const memo = memoize(() => Promise.resolve(Math.random()))
        Promise.all([memo(), memo()])
            .then(([a, b]) => assert(a === b) && assert(a instanceof Number))
    })

})