Selaa lähdekoodia

reflect api change

pull/342/head
Guillaume Vincent 8 vuotta sitten
vanhempi
commit
9d91198c37
6 muutettua tiedostoa jossa 31 lisäystä ja 81 poistoa
  1. +6
    -6
      src/app/Entries/EntryForm.vue
  2. +0
    -1
      src/app/Entries/UpdateEntry.vue
  3. +1
    -5
      src/app/Entries/newEntry.vue
  4. +2
    -2
      src/app/Index.vue
  5. +4
    -4
      tests/entries.tests.js
  6. +18
    -63
      tests/helpers.js

+ 6
- 6
src/app/Entries/EntryForm.vue Näytä tiedosto

@@ -2,15 +2,15 @@
<form id="password-generator-form"> <form id="password-generator-form">
<div class="form-group row"> <div class="form-group row">
<div class="col-lg-6 m-t-1"> <div class="col-lg-6 m-t-1">
<label for="pg-email" class="sr-only">
<label for="pg-login" class="sr-only">
{{ $t('passwordgenerator.who_are_you') }} {{ $t('passwordgenerator.who_are_you') }}
</label> </label>
<input id="pg-email"
<input id="pg-login"
class="form-control" class="form-control"
type="text" type="text"
placeholder="{{ $t('passwordgenerator.who_are_you') }}" placeholder="{{ $t('passwordgenerator.who_are_you') }}"
value="{{entry.email}}"
v-model="entry.email"
value="{{entry.login}}"
v-model="entry.login"
autofocus autofocus
autocomplete="off" autocomplete="off"
autocorrect="off" autocorrect="off"
@@ -79,7 +79,7 @@
<label for="passwordLength" class="sr-only"> <label for="passwordLength" class="sr-only">
{{ $t('passwordgenerator.length') }} {{ $t('passwordgenerator.length') }}
</label> </label>
<div class="input-group input-group-sm">
<div class="input-group">
<span class="input-group-addon" id="passwordLengthAddon"> <span class="input-group-addon" id="passwordLengthAddon">
{{ $t('passwordgenerator.length') }} {{ $t('passwordgenerator.length') }}
</span> </span>
@@ -93,7 +93,7 @@
<label for="passwordCounter" class="sr-only"> <label for="passwordCounter" class="sr-only">
{{ $t('passwordgenerator.counter') }} {{ $t('passwordgenerator.counter') }}
</label> </label>
<div class="input-group input-group-sm">
<div class="input-group">
<span class="input-group-addon" id="passwordCounterAddon"> <span class="input-group-addon" id="passwordCounterAddon">
{{ $t('passwordgenerator.counter') }} {{ $t('passwordgenerator.counter') }}
</span> </span>


+ 0
- 1
src/app/Entries/UpdateEntry.vue Näytä tiedosto

@@ -39,7 +39,6 @@
update() { update() {
http.entries.update(this.entry) http.entries.update(this.entry)
.then(() => { .then(() => {

logging.success(this.$t('entries.entry_update')); logging.success(this.$t('entries.entry_update'));
}) })
.catch((err) => { .catch((err) => {


+ 1
- 5
src/app/Entries/newEntry.vue Näytä tiedosto

@@ -41,7 +41,7 @@
data() { data() {
return { return {
entry: { entry: {
email: '',
login: '',
site: '', site: '',
password: { password: {
counter: 1, counter: 1,
@@ -56,10 +56,6 @@
}, },
methods: { methods: {
create() { create() {
if (this.entry.site === '') {
logging.error(this.$t('entries.site_mandatory'));
return;
}
http.entries.create(this.entry) http.entries.create(this.entry)
.then(() => { .then(() => {
$('#newEntryModal').modal('hide'); $('#newEntryModal').modal('hide');


+ 2
- 2
src/app/Index.vue Näytä tiedosto

@@ -58,7 +58,7 @@
<p>{{ entry.site }}</p> <p>{{ entry.site }}</p>
<footer> <footer>
<small class="text-muted"> <small class="text-muted">
{{ entry.email }}
{{ entry.login }}
</small> </small>
</footer> </footer>
</blockquote> </blockquote>
@@ -75,7 +75,7 @@
{{ $t('index.previous') }} {{ $t('index.previous') }}
</button> </button>
</div> </div>
<div class="col-xs-4 text-xs-center">
<div class="col-xs-4 text-xs-center" v-if="numberPages > 1">
{{ currentPage }} / {{ numberPages }} {{ currentPage }} / {{ numberPages }}
</div> </div>
<div class="col-xs-4 text-xs-right"> <div class="col-xs-4 text-xs-right">


+ 4
- 4
tests/entries.tests.js Näytä tiedosto

@@ -23,7 +23,7 @@ suite('entries', () => {
], ],
"length": 12 "length": 12
}, },
"email": "guillaume@oslab.fr",
"login": "guillaume@lesspass.com",
}; };
}); });


@@ -39,7 +39,7 @@ suite('entries', () => {
nock('http://localhost/').post('/api/entries/', entry).reply(201, entry); nock('http://localhost/').post('/api/entries/', entry).reply(201, entry);
entries.create(entry) entries.create(entry)
.then((newEntry) => { .then((newEntry) => {
assert.equal(entry.email, newEntry.email);
assert.equal(entry.login, newEntry.login);
done(); done();
}); });
}); });
@@ -58,7 +58,7 @@ suite('entries', () => {
nock('http://localhost/').get('/api/entries/').query(true).reply(200, {entries: entriesGetAll}); nock('http://localhost/').get('/api/entries/').query(true).reply(200, {entries: entriesGetAll});
entries.all().then((response) => { entries.all().then((response) => {
assert.equal(200, response.status); assert.equal(200, response.status);
assert.equal(5, response.data.entries.results.length);
assert.equal(entriesGetAll.count, response.data.entries.results.length);
done(); done();
}); });
}); });
@@ -86,7 +86,7 @@ suite('entries', () => {
var updatedEntry = JSON.parse(JSON.stringify(entriesGetOne)); var updatedEntry = JSON.parse(JSON.stringify(entriesGetOne));
updatedEntry.email = 'test2@lesspass.com'; updatedEntry.email = 'test2@lesspass.com';
var headers = {reqheaders: {'Authorization': 'JWT ' + token}}; var headers = {reqheaders: {'Authorization': 'JWT ' + token}};
nock('http://localhost/', headers).put('/api/entries/d1ff1ae9-bb29-469d-8e5e-8a387f529de0/').reply(200, updatedEntry);
nock('http://localhost/', headers).put(`/api/entries/${updatedEntry.id}/`).reply(200, updatedEntry);
entries.update(updatedEntry) entries.update(updatedEntry)
.then((entry) => { .then((entry) => {
assert.equal(updatedEntry.email, entry.email); assert.equal(updatedEntry.email, entry.email);


+ 18
- 63
tests/helpers.js Näytä tiedosto

@@ -14,78 +14,33 @@ after(()=> {
}); });


const entriesGetAll = { const entriesGetAll = {
"count": 5,
"count": 3,
"next": null, "next": null,
"previous": null, "previous": null,
"results": [{ "results": [{
"id": "d7ef8d1e-b5e3-4227-926b-29f236c49c6b",
"site": "site 1",
"id": "535a439d-49cf-4b32-844f-d367640a0a9b",
"site": "facebook.com",
"login": "test@lesspass.com",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12}, "password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-04T12:59:42.815400",
"modified": "2016-04-04T12:59:42.815431"
"created": "2016-04-06T11:34:46.719242",
"modified": "2016-04-06T11:34:46.719265"
}, { }, {
"id": "1e532990-66c4-4522-b033-ce6ee13b37c5",
"site": "site 2",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-04T12:59:19.005800",
"modified": "2016-04-04T12:59:19.005821"
}, {
"id": "61dc47cc-9f78-4ad1-acda-61914227b2cd",
"site": "site 3",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-04T08:12:06.686885",
"modified": "2016-04-04T08:12:06.686909"
"id": "a45b8a54-485f-4e8e-a03e-9d2ae169514c",
"site": "twitter.com",
"login": "test@lesspass.com",
"password": {"counter": 10, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 14},
"created": "2016-04-06T11:32:15.537767",
"modified": "2016-04-06T11:33:46.951174"
}, { }, {
"id": "57a3e0ac-08a4-447b-831c-7863896ea210",
"site": "site 4",
"id": "d7fe3061-cb3b-492e-bc1e-b88c79acaa0c",
"site": "lesspass.com",
"login": "test@lesspass.com",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12}, "password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-04T08:11:55.130015",
"modified": "2016-04-04T08:11:55.130037"
}, {
"id": "772abd32-5712-48c0-ba81-8a1a3748757e",
"site": "site 5",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-01T19:57:15.738606",
"modified": "2016-04-01T19:57:15.738627"
"created": "2016-04-06T11:27:49.962268",
"modified": "2016-04-06T11:31:05.975255"
}] }]
}; };
export {entriesGetAll}; export {entriesGetAll};


var entriesGetOne = {
"id": "d1ff1ae9-bb29-469d-8e5e-8a387f529de0",
"site": "lesspass.com",
"password": {"counter": 1, "settings": ["lowercase", "uppercase", "numbers", "symbols"], "length": 12},
"title": null,
"username": null,
"email": "test@lesspass.com",
"description": null,
"url": null,
"created": "2016-04-05T16:44:46.210303",
"modified": "2016-04-05T16:44:46.210325"
};
var entriesGetOne = JSON.parse(JSON.stringify(entriesGetAll.results[0]));
export {entriesGetOne}; export {entriesGetOne};

Ladataan…
Peruuta
Tallenna