michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const { uuid } = require('sdk/util/uuid'); michael@0: michael@0: exports['test generate uuid'] = function(assert) { michael@0: let signature = /{[0-9a-f\-]+}/ michael@0: let first = String(uuid()); michael@0: let second = String(uuid()); michael@0: michael@0: assert.ok(signature.test(first), 'first guid has a correct signature'); michael@0: assert.ok(signature.test(second), 'second guid has a correct signature'); michael@0: assert.notEqual(first, second, 'guid generates new guid on each call'); michael@0: }; michael@0: michael@0: exports['test parse uuid'] = function(assert) { michael@0: let firefoxUUID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'; michael@0: let actual = uuid(firefoxUUID); michael@0: michael@0: assert.equal(actual.number, firefoxUUID, 'uuid parsed given string'); michael@0: assert.equal(String(actual), firefoxUUID, 'serializes to the same value'); michael@0: }; michael@0: michael@0: require('test').run(exports);