UNPKG

wasteful-scope

Version:

OAuth2 scope utilities for the wasteful scope parsing, comparing, merging, etc

47 lines (40 loc) 1.03 kB
'use strict'; module.exports.create = function (groups) { var stringify = require('../index').create(groups).stringify , str , expected = 'me:phone,email:phone,email:tel,sms me.friends:name,birthday::tel,sms' ; str = stringify({ 'me': { group: 'me' , readable: ['phone,email'] , writeable: ['phone,email'] , executable: ['tel,sms'] } , 'me.friends': { group: 'me.friends' , readable: ['name,birthday'] , writeable: [] , executable: ['tel,sms'] } }); if (expected !== str) { throw new Error("[1] stringified does not match object: " + expected); } str = stringify([ { group: 'me' , readable: ['phone,email'] , writeable: ['phone,email'] , executable: ['tel,sms'] } , { group: 'me.friends' , readable: ['name,birthday'] , writeable: [] , executable: ['tel,sms'] } ]); if (expected !== str) { throw new Error("[2] stringified does not match object: " + expected); } console.log('[stringify] PASS'); };