MCPcopy Create free account
hub / github.com/cutedCha/noteBoook / createBookState

Function createBookState

tests/book.property.test.js:25–80  ·  view source on GitHub ↗

* Helper function to create a fresh BookUI instance for testing * @param {number} currentPage - Current page number * @param {number} totalPages - Total number of pages * @returns {object} - BookUI-like object for testing

(currentPage, totalPages)

Source from the content-addressed store, hash-verified

23 * @returns {object} - BookUI-like object for testing
24 */
25 function createBookState(currentPage, totalPages) {
26 return {
27 currentPage: currentPage,
28 totalPages: totalPages,
29 isAnimating: false,
30 viewMode: 'double',
31
32 /**
33 * Check if previous page navigation should be disabled
34 * @returns {boolean} - True if prev navigation should be disabled
35 */
36 isPrevDisabled: function() {
37 return this.currentPage <= 1;
38 },
39
40 /**
41 * Check if next page navigation should be disabled
42 * @returns {boolean} - True if next navigation should be disabled
43 */
44 isNextDisabled: function() {
45 return this.currentPage >= this.totalPages;
46 },
47
48 /**
49 * Attempt to flip to previous page
50 * @returns {boolean} - True if flip was successful
51 */
52 flipPrev: function() {
53 if (this.isPrevDisabled()) {
54 return false;
55 }
56 this.currentPage--;
57 return true;
58 },
59
60 /**
61 * Attempt to flip to next page
62 * @returns {boolean} - True if flip was successful
63 */
64 flipNext: function() {
65 if (this.isNextDisabled()) {
66 return false;
67 }
68 this.currentPage++;
69 return true;
70 },
71
72 /**
73 * Check if current page is within valid range
74 * @returns {boolean} - True if page is valid
75 */
76 isPageValid: function() {
77 return this.currentPage >= 1 && this.currentPage <= this.totalPages;
78 }
79 };
80 }
81
82 /**

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected