url.js 758 B

123456789101112131415161718192021222324252627282930313233
  1. import Vue from 'vue';
  2. describe('Vue.url', function () {
  3. it('data{/id}', function () {
  4. expect(Vue.url('data{/id}')).toBe('data');
  5. expect(Vue.url('data{/id}', {id: 1})).toBe('data/1');
  6. });
  7. it('data{/array}', function () {
  8. expect(Vue.url('data{?array}')).toBe('data');
  9. expect(Vue.url('data{?array}', {array: [1,2,3]})).toBe('data?array=1,2,3');
  10. });
  11. it('{+path}data', function () {
  12. expect(Vue.url('{+path}data')).toBe('data');
  13. expect(Vue.url('{+path}data', {path: 'path1/path2/'})).toBe('path1/path2/data');
  14. });
  15. it('{+base}data', function () {
  16. Vue.url.options.params.base = 'base/path/';
  17. expect(Vue.url('{+base}data')).toBe('base/path/data');
  18. });
  19. });