Browse Source

Fix order of completion (#447)

pull/448/head
Xavier DETANT 5 years ago
committed by Guillaume Vincent
parent
commit
8772585e88
2 changed files with 14 additions and 5 deletions
  1. +4
    -0
      packages/lesspass-pure/src/components/InputSite.vue
  2. +10
    -5
      packages/lesspass-pure/src/components/input-site.test.js

+ 4
- 0
packages/lesspass-pure/src/components/InputSite.vue View File

@@ -59,6 +59,10 @@
this.$emit("passwordProfileSelected", password.value); this.$emit("passwordProfileSelected", password.value);
} }
}; };
this.awesomplete.sort = (a,b) => {
return a.value.site.localeCompare(b.value.site) ||
a.value.login.localeCompare(b.value.login);
}
}, },
computed: { computed: {
site: { site: {


+ 10
- 5
packages/lesspass-pure/src/components/input-site.test.js View File

@@ -71,17 +71,22 @@ describe('InputSite', () => {
let options = optionsFor(wrapper); let options = optionsFor(wrapper);
expect(options.length).toBe(0); expect(options.length).toBe(0);
}); });
it(`prints all options`, () => {
it(`prints options sorted by site then login`, () => {
const wrapper = createWrapper({ const wrapper = createWrapper({
passwords: [ passwords: [
{site: "lesspass", login: "guillaume"},
{site: "passless", login: "xavier"},
{site: "passless", login: "guillaume"},
{site: "lesspass", login: "xavier"}, {site: "lesspass", login: "xavier"},
{site: "lesspass", login: "guillaume"}]
]
}); });
inputField(wrapper).setValue("le"); inputField(wrapper).setValue("le");
let options = optionsFor(wrapper); let options = optionsFor(wrapper);
expect(options.length).toBe(2);
expect(options.at(0).text()).toContain("lesspass");
expect(options.at(1).text()).toContain("lesspass");
expect(options.length).toBe(4);
expect(options.at(0).text()).toBe("lesspass guillaume");
expect(options.at(1).text()).toBe("lesspass xavier");
expect(options.at(2).text()).toBe("passless guillaume");
expect(options.at(3).text()).toBe("passless xavier");
}); });
}); });
describe('completion', () => { describe('completion', () => {


Loading…
Cancel
Save