Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
util_test.js 969 B
import { hash } from '../src/util.js'
import { generateSimpleViteManifest } from './util.js'
import { expect } from 'chai'

describe('Util', function () {
  describe('hash function', function () {
    it('computes the hash', function () {
      const manifest = generateSimpleViteManifest({
        'example.js': { imports: ['test.css'] },
        'test.css': { }
      })
      expect(hash(manifest)).to.equal('2245696177')
    })

    it('the hash changes when the manifest changes', function () {
      const manifest = generateSimpleViteManifest({
        'example.js': { imports: ['test.css'] },
        'test.css': { }
      })
      const manifestChanged = generateSimpleViteManifest({
        'example.js': { imports: ['test1.css'] },
        'test1.css': { }
      })

      expect(hash(manifest)).not.to.equal(hash(manifestChanged))
      expect(hash(manifest)).to.equal('2245696177')
      expect(hash(manifestChanged)).to.equal('2547998666')
    })
  })
})