@@ -257,80 +257,167 @@ describe(
257257describe (
258258 'prefix and suffix' ,
259259 ( ) => {
260- beforeEach (
261- ( ) => {
262- cy . visit ( getUrl ( { prefix : '$' , suffix : 'CAD' } ) ) ;
263- cy . reload ( ) ;
264- }
265- ) ;
266-
267- it (
268- 'should format when input was created' ,
269- ( ) => {
270- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
271- }
272- ) ;
273-
274- it (
275- 'shouldn\'t allow type a letter' ,
276- ( ) => {
277- cy . get ( 'input' ) . type ( 'abc' ) ;
278- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
279- }
280- ) ;
281-
282- it (
283- 'should format when type only cents' ,
284- ( ) => {
285- cy . get ( 'input' ) . type ( '1' ) ;
286- cy . get ( 'input' ) . should ( 'have.value' , '$0,01CAD' ) ;
287-
288- cy . get ( 'input' ) . type ( '{backspace}' ) ;
289- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
290-
291- cy . get ( 'input' ) . type ( '12' ) ;
292- cy . get ( 'input' ) . should ( 'have.value' , '$0,12CAD' ) ;
293-
294- cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 2 ) ) ;
295- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
296-
297- cy . get ( 'input' ) . type ( '66' ) ;
298- cy . get ( 'input' ) . should ( 'have.value' , '$0,66CAD' ) ;
299- }
300- ) ;
301-
302- it (
303- 'should format dozens' ,
260+ describe (
261+ 'common behaviour' ,
304262 ( ) => {
305- cy . get ( 'input' ) . type ( '123' ) ;
306- cy . get ( 'input' ) . should ( 'have.value' , '$1,23CAD' ) ;
307-
308-
309- cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 3 ) ) ;
310- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
311-
312- cy . get ( 'input' ) . type ( '1234' ) ;
313- cy . get ( 'input' ) . should ( 'have.value' , '$12,34CAD' ) ;
314-
315- cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 4 ) ) ;
316- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
317-
318- cy . get ( 'input' ) . type ( '6666' ) ;
319- cy . get ( 'input' ) . should ( 'have.value' , '$66,66CAD' ) ;
263+ beforeEach (
264+ ( ) => {
265+ cy . visit ( getUrl ( { prefix : '$' , suffix : 'CAD' } ) ) ;
266+ cy . reload ( ) ;
267+ }
268+ ) ;
269+
270+ it (
271+ 'should format when input was created' ,
272+ ( ) => {
273+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
274+ }
275+ ) ;
276+
277+ it (
278+ 'shouldn\'t allow type a letter' ,
279+ ( ) => {
280+ cy . get ( 'input' ) . type ( 'abc' ) ;
281+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
282+ }
283+ ) ;
284+
285+ it (
286+ 'should format when type only cents' ,
287+ ( ) => {
288+ cy . get ( 'input' ) . type ( '1' ) ;
289+ cy . get ( 'input' ) . should ( 'have.value' , '$0,01CAD' ) ;
290+
291+ cy . get ( 'input' ) . type ( '{backspace}' ) ;
292+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
293+
294+ cy . get ( 'input' ) . type ( '12' ) ;
295+ cy . get ( 'input' ) . should ( 'have.value' , '$0,12CAD' ) ;
296+
297+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 2 ) ) ;
298+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
299+
300+ cy . get ( 'input' ) . type ( '66' ) ;
301+ cy . get ( 'input' ) . should ( 'have.value' , '$0,66CAD' ) ;
302+ }
303+ ) ;
304+
305+ it (
306+ 'should format dozens' ,
307+ ( ) => {
308+ cy . get ( 'input' ) . type ( '123' ) ;
309+ cy . get ( 'input' ) . should ( 'have.value' , '$1,23CAD' ) ;
310+
311+
312+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 3 ) ) ;
313+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
314+
315+ cy . get ( 'input' ) . type ( '1234' ) ;
316+ cy . get ( 'input' ) . should ( 'have.value' , '$12,34CAD' ) ;
317+
318+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 4 ) ) ;
319+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
320+
321+ cy . get ( 'input' ) . type ( '6666' ) ;
322+ cy . get ( 'input' ) . should ( 'have.value' , '$66,66CAD' ) ;
323+ }
324+ ) ;
325+
326+ it (
327+ 'should format hundreds' ,
328+ ( ) => {
329+ cy . get ( 'input' ) . type ( '12345' ) ;
330+ cy . get ( 'input' ) . should ( 'have.value' , '$123,45CAD' ) ;
331+
332+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 5 ) ) ;
333+ cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
334+
335+ cy . get ( 'input' ) . type ( '66699' ) ;
336+ cy . get ( 'input' ) . should ( 'have.value' , '$666,99CAD' ) ;
337+ }
338+ ) ;
320339 }
321340 ) ;
322-
323- it (
324- 'should format hundreds' ,
325- ( ) => {
326- cy . get ( 'input' ) . type ( '12345' ) ;
327- cy . get ( 'input' ) . should ( 'have.value' , '$123,45CAD' ) ;
328-
329- cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 5 ) ) ;
330- cy . get ( 'input' ) . should ( 'have.value' , '$0,00CAD' ) ;
331-
332- cy . get ( 'input' ) . type ( '66699' ) ;
333- cy . get ( 'input' ) . should ( 'have.value' , '$666,99CAD' ) ;
341+
342+ describe (
343+ 'wrong behaviour prefix and suffix with space' ,
344+ ( ) => {
345+ beforeEach (
346+ ( ) => {
347+ cy . visit ( getUrl ( { prefix : '$ ' , suffix : ' CAD' } ) ) ;
348+ cy . reload ( ) ;
349+ }
350+ ) ;
351+
352+ it (
353+ 'should format when input was created' ,
354+ ( ) => {
355+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
356+ }
357+ ) ;
358+
359+ it (
360+ 'shouldn\'t allow type a letter' ,
361+ ( ) => {
362+ cy . get ( 'input' ) . type ( 'abc' ) ;
363+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
364+ }
365+ ) ;
366+
367+ it (
368+ 'should format when type only cents' ,
369+ ( ) => {
370+ cy . get ( 'input' ) . type ( '1' ) ;
371+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,01 CAD' ) ;
372+
373+ cy . get ( 'input' ) . type ( '{backspace}' ) ;
374+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
375+
376+ cy . get ( 'input' ) . type ( '12' ) ;
377+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,12 CAD' ) ;
378+
379+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 2 ) ) ;
380+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
381+
382+ cy . get ( 'input' ) . type ( '66' ) ;
383+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,66 CAD' ) ;
384+ }
385+ ) ;
386+
387+ it (
388+ 'should format dozens' ,
389+ ( ) => {
390+ cy . get ( 'input' ) . type ( '123' ) ;
391+ cy . get ( 'input' ) . should ( 'have.value' , '$ 1,23 CAD' ) ;
392+
393+
394+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 3 ) ) ;
395+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
396+
397+ cy . get ( 'input' ) . type ( '1234' ) ;
398+ cy . get ( 'input' ) . should ( 'have.value' , '$ 12,34 CAD' ) ;
399+
400+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 4 ) ) ;
401+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
402+
403+ cy . get ( 'input' ) . type ( '6666' ) ;
404+ cy . get ( 'input' ) . should ( 'have.value' , '$ 66,66 CAD' ) ;
405+ }
406+ ) ;
407+
408+ it (
409+ 'should format hundreds' ,
410+ ( ) => {
411+ cy . get ( 'input' ) . type ( '12345' ) ;
412+ cy . get ( 'input' ) . should ( 'have.value' , '$ 123,45 CAD' ) ;
413+
414+ cy . get ( 'input' ) . type ( '{backspace}' . repeat ( 5 ) ) ;
415+ cy . get ( 'input' ) . should ( 'have.value' , '$ 0,00 CAD' ) ;
416+
417+ cy . get ( 'input' ) . type ( '66699' ) ;
418+ cy . get ( 'input' ) . should ( 'have.value' , '$ 666,99 CAD' ) ;
419+ }
420+ ) ;
334421 }
335422 ) ;
336423 }
0 commit comments